package cn.mcch.investigator.utils;

import android.app.DatePickerDialog;
import android.content.Context;
import android.support.v4.app.FragmentManager;
import android.widget.AdapterView;

import java.util.Calendar;
import java.util.List;

import cn.mcch.investigator.dialog.BaseDialog;
import cn.mcch.investigator.dialog.CancelRescueDialog;
import cn.mcch.investigator.dialog.CarAreaArmyDialog;
import cn.mcch.investigator.dialog.CarCodeDialog;
import cn.mcch.investigator.dialog.CarTypeChildListDialog;
import cn.mcch.investigator.dialog.ExitDialog;
import cn.mcch.investigator.dialog.LoadingDialog;
import cn.mcch.investigator.dialog.MoreRecommendListDialog;
import cn.mcch.investigator.dialog.OrderAttrListDialog;
import cn.mcch.investigator.dialog.RiskAreaUrbanListDialog;
import cn.mcch.investigator.listener.OnCommonClickListener;
import cn.mcch.investigator.model.bean.AreaChild;
import cn.mcch.investigator.model.bean.CarType;
import cn.mcch.investigator.model.bean.ConfChild;
import cn.mcch.investigator.model.bean.RecommendCarTypeBean;

/**
 * Created by Administrator on 2016/12/17.
 */
public class DialogUtils {


    public static ExitDialog showExitDialog(FragmentManager manager, String msg, String negative, String positive, OnCommonClickListener l) {
        ExitDialog dialog = new ExitDialog();
        dialog.setMessage(msg).setNegative(negative).setPositive(positive).setOnClickListener(l).show(manager, "");
        return dialog;
    }

    public static CancelRescueDialog showCancelRescueDialog(FragmentManager manager, OnCommonClickListener l, String orderNo) {
        CancelRescueDialog dialog = new CancelRescueDialog();
        dialog.setOnClickListener(l).setOrderNo(orderNo).show(manager, "");
        return dialog;
    }

    public static LoadingDialog showLoadingDialog(FragmentManager manager, String msg) {
        LoadingDialog dialog = new LoadingDialog();
        dialog.setMessage(msg).show(manager, "");
        return dialog;
    }

    public static CarAreaArmyDialog showCarAreaArmyDialog(FragmentManager manager, AdapterView.OnItemClickListener l, String[] data, int numColumns) {
        CarAreaArmyDialog dialog = new CarAreaArmyDialog();
        dialog.setOnItemClickListener(l).setData(data).setNumColumns(numColumns).show(manager, "");
        return dialog;
    }

    public static CarCodeDialog showCarCodeDialog(FragmentManager manager, OnCommonClickListener l, String[] data, int numColumns) {
        CarCodeDialog dialog = new CarCodeDialog();
        dialog.setOnCommonClickListener(l).setData(data).setNumColumns(numColumns).show(manager, "");
        return dialog;
    }

    public static OrderAttrListDialog showOrderAttrListDialog(int type, FragmentManager manager, OnCommonClickListener l, List<ConfChild> datas) {
        String title = null;
        switch (type) {
            case 1:
                title = "属性选择";
                break;
            case 2:
                title = "出险区域市区选择";
                break;
            case 3:
                title = "意向区域市区选择";
                break;
            case 4:
                title = "估损金额选择";
                break;
            case 5:
                title = "救援类型选择";
                break;
            default:
                break;
        }

        OrderAttrListDialog dialog = new OrderAttrListDialog();
        dialog.setOnCommonClickListener(l).setDatas(datas).setTitle(title).show(manager, "");
        return dialog;
    }

    public static RiskAreaUrbanListDialog showRiskAreaUrbanListDialog(int type, FragmentManager manager, OnCommonClickListener l, List<AreaChild> datas) {

        String title = null;
        switch (type) {
            case 1:
                title = "出险区域城市选择";
                break;
            case 2:
                title = "意向区域城市选择";
                break;
            default:
                break;
        }
        RiskAreaUrbanListDialog dialog = new RiskAreaUrbanListDialog();
        dialog.setOnCommonClickListener(l).setDatas(datas).setTitle(title).show(manager, "");
        return dialog;
    }

    public static CarTypeChildListDialog showCarTypeChildListDialog(FragmentManager manager, OnCommonClickListener l, List<CarType> datas) {
        CarTypeChildListDialog dialog = new CarTypeChildListDialog();
        dialog.setCancelable(false);
        dialog.setOnCommonClickListener(l).setDatas(datas).setTitle("厂商选择").show(manager, "");
        return dialog;
    }

    public static void showDateDialog(Context context, DatePickerDialog.OnDateSetListener l) {
        Calendar c = Calendar.getInstance();
        new DatePickerDialog(context, l, c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH)).show();
    }

    public static BaseDialog showMoreRecommendListDialog(FragmentManager manager, OnCommonClickListener l, List<RecommendCarTypeBean> datas) {
        MoreRecommendListDialog dialog = new MoreRecommendListDialog();
        dialog.setOnCommonClickListener(l).setDatas(datas).setTitle("推修车行选择").show(manager, "");
        return dialog;
    }
}
